﻿namespace Transponder_Core
{
    /// <summary>
    ///  通用 响应
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public class ResultRespose<T>
    {
        /// <summary>
        /// 响应 码
        /// </summary>
        public int Code { get; set; }
        /// <summary>
        /// 响应 消息
        /// </summary>
        public string Message { get; set; } = string.Empty;
        /// <summary>
        /// 响应 数据
        /// </summary>
        public T Data { get; set; }=default!;

        /// <summary>
        /// 
        /// </summary>

        public static ResultRespose<string> OK = new ResultRespose<string>()
        {
            Code = ResposeCode.Ok,
        };


        public static ResultRespose<string> Bad = new ResultRespose<string>()
        {
            Code = ResposeCode.Bad,
        };

       
        /// <summary>
        /// 通用
        /// </summary>
        /// <param name="data"></param>
        /// <param name="message"></param>
        /// <returns></returns>
        public static ResultRespose<T> OKWithData(T data,string message="")
        {
            return new ResultRespose<T>()
            {
                Code = ResposeCode.Ok,
                Data = data,
                Message = message   
            };
        }
        /// <summary>
        /// 通用
        /// </summary>
        /// <param name="data"></param>
        /// <param name="message"></param>
        /// <returns></returns>
        public static ResultRespose<T> BadWithData(T data, string message = "")
        {
            return new ResultRespose<T>()
            {
                Code = ResposeCode.Bad,
                Data = data,
                Message = message
            };
        }

    }
}
